1
|
|
|
// Base path --> assets/html |
2
|
|
|
const electron = require('electron'), |
3
|
|
|
path = require('path'); |
|
|
|
|
4
|
|
|
|
5
|
|
|
require('../js/renderer/sw.js'); |
6
|
|
|
require('../js/renderer/bw.js'); |
7
|
|
|
require('../js/renderer/bwa.js'); |
8
|
|
|
require('../js/renderer/bwm.js'); |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
window.$ = window.jQuery = require('jquery'); |
12
|
|
|
|
13
|
|
|
const { |
14
|
|
|
appSettings |
15
|
|
|
} = require('../js/appsettings.js'); |
16
|
|
|
|
17
|
|
|
const { |
18
|
|
|
ipcRenderer, |
19
|
|
|
remote, |
20
|
|
|
dialog |
21
|
|
|
} = electron; |
22
|
|
|
|
23
|
|
|
$(document).ready(function() { // When document is ready |
24
|
|
|
ipcRenderer.send('app:debug', "Document is ready"); |
25
|
|
|
|
26
|
|
|
startup(); |
27
|
|
|
|
28
|
|
|
// Button/Toggle special menu items |
29
|
|
|
$('#navButtonExtendedmenu').click(function() { |
30
|
|
|
ipcRenderer.send('app:debug', "#navButtonExtendedmenu was clicked"); |
31
|
|
|
$('#navButtonExtendedmenu').toggleClass('is-active'); |
32
|
|
|
$('.is-specialmenu').toggleClass('is-hidden'); |
33
|
|
|
}); |
34
|
|
|
|
35
|
|
|
// Window minimize button |
36
|
|
|
$('#navButtonMinimize').click(function() { |
37
|
|
|
ipcRenderer.send('app:debug', "#navButtonMinimize was clicked"); |
38
|
|
|
remote.getCurrentWindow().minimize(); |
39
|
|
|
}); |
40
|
|
|
|
41
|
|
|
// Window exit button |
42
|
|
|
$('#navButtonExit').click(function() { |
43
|
|
|
ipcRenderer.send('app:debug', "#navButtonExit was clicked"); |
44
|
|
|
remote.getCurrentWindow().close(); |
45
|
|
|
}); |
46
|
|
|
|
47
|
|
|
// Assign [ESC] to close message/modal |
48
|
|
|
$(document).keyup(function(event) { |
49
|
|
|
if (event.keyCode === 27) { |
50
|
|
|
ipcRenderer.send('app:debug', "Used [ESC] key, {0}".format(event.keyCode)); |
51
|
|
|
if ($('#swMessageWhois').hasClass('is-active')) { |
52
|
|
|
$('#swMessageWhoisClose').click(); |
53
|
|
|
} else if ($('.notification')) { |
54
|
|
|
$('.notification:not(.is-hidden)').addClass('is-hidden'); |
55
|
|
|
if ($('#swTableWhoisInfo:not(.is-hidden)')) { |
56
|
|
|
$('#swTableWhoisInfo').addClass('is-hidden'); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
}); |
61
|
|
|
|
62
|
|
|
// Prevent drop redirect |
63
|
|
|
$(document).on('drop', function(event) { |
64
|
|
|
ipcRenderer.send('app:debug', "Preventing drag and drop redirect"); |
65
|
|
|
event.preventDefault(); |
66
|
|
|
return false; |
67
|
|
|
}); |
68
|
|
|
|
69
|
|
|
// Prevent drag over redirect |
70
|
|
|
$(document).on('dragover', function(event) { |
71
|
|
|
event.preventDefault(); |
72
|
|
|
return false; |
73
|
|
|
}); |
74
|
|
|
|
75
|
|
|
// Toggle devtools |
76
|
|
|
$('#navButtonDevtools').click(function() { |
77
|
|
|
remote.getCurrentWindow().toggleDevTools(); |
78
|
|
|
ipcRenderer.send('app:debug', "#navButtonDevtools was clicked"); |
79
|
|
|
}); |
80
|
|
|
|
81
|
|
|
// Toggle between tabs |
82
|
|
|
$('section.tabs ul li').click(function() { |
83
|
|
|
var tabName = $(this).attr('data-tab'); |
84
|
|
|
|
85
|
|
|
if (tabName != '#') { |
86
|
|
|
$('section.tabs ul li').removeClass('is-active'); |
87
|
|
|
$('div.container .tab-content').removeClass('current'); |
88
|
|
|
|
89
|
|
|
$(this).addClass('is-active'); |
90
|
|
|
$("#" + tabName).addClass('current'); |
91
|
|
|
} |
92
|
|
|
ipcRenderer.send('app:debug', "#section.tabs switched to data tab, {0}".format(tabName)); |
93
|
|
|
}); |
94
|
|
|
|
95
|
|
|
// Delete notifications |
96
|
|
|
$('.delete').click(function() { |
97
|
|
|
ipcRenderer.send('app:debug', ".delete (notifications) was clicked"); |
98
|
|
|
var notificationId = $(this).attr('data-notif'); |
99
|
|
|
|
100
|
|
|
$('#' + notificationId).addClass('is-hidden'); |
101
|
|
|
}); |
102
|
|
|
|
103
|
|
|
}); |
104
|
|
|
|
105
|
|
|
// Startup checks |
106
|
|
|
function startup() { |
107
|
|
|
var { |
108
|
|
|
navigation |
109
|
|
|
} = appSettings; |
110
|
|
|
ipcRenderer.send('app:debug', "'navigation.devtools': {0}".format(navigation.devtools)); |
111
|
|
|
if (navigation.devtools === true) { |
112
|
|
|
$('#navTabDevtools').removeClass('is-force-hidden'); |
113
|
|
|
} |
114
|
|
|
ipcRenderer.send('app:debug', "'navigation.extendedcollapsed': {0}".format(navigation.extendedcollapsed)); |
115
|
|
|
if (navigation.extendedcollapsed === true) { |
116
|
|
|
$('#navButtonExpandedmenu').toggleClass('is-active'); |
117
|
|
|
$('.is-specialmenu').toggleClass('is-hidden'); |
118
|
|
|
} |
119
|
|
|
ipcRenderer.send('app:debug', "'navigation.extendedmenu': {0}".format(navigation.extendedmenu)); |
120
|
|
|
if (navigation.extendedmenu === false) { |
121
|
|
|
$('#navButtonExpandedmenu').addClass('is-force-hidden'); |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/* |
126
|
|
|
// Load different panel parts ////////////////// |
127
|
|
|
function loadContents() { |
128
|
|
|
$('#include.navbar').load(path.join(__dirname, '../html/navigation/navbar.html')); |
129
|
|
|
$('#include.navbar.tabs').load(path.join(__dirname, '../html/navigation/navbar.tabs.html')); |
130
|
|
|
} |
131
|
|
|
*/ |
132
|
|
|
|